<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>缓动效果</title>
    <script src="./animate.js"></script>
    <style>
        .box1 {
            position: absolute;
            top: 0;
            left: 0;
            width: 100px;
            height: 100px;
            background-color: orange;
        }

        .box2 {
            position: absolute;
            top: 200px;
            left: 0;
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="box1">
        盒子1
    </div><br>
    <br>
    <br>
    <br>
    <br>
    <button>移动到800</button>
    <button>移动到500</button>
    <div class="box2">
        盒子2
    </div>
    <script>
        var box1 = document.querySelector('.box1');
        var box2 = document.querySelector('.box2');
        var btn = document.querySelectorAll('button');

        btn[0].onclick = function () {
            animate(box1, 800, function () {
                box1.style.background = 'pink';
            });
        }
        btn[1].onclick = function () {
            animate(box1, 500);
        }
        // animate(box2, 500);

    </script>
</body>

</html>